import { observable, action } from 'mobx';
import { Form } from 'weaver-mobile-page';

import { getMailAccount } from '../../apis/setting';

import TableListStore from './tableListStore';

const initState = {
  condition: [],
  accountId: undefined,
  tableListParams: {
    url: getMailAccount,
    params: {},
  },
  sentItemsVal: [],
};

export default class MailAccountStore {
  @observable tableListStore = new TableListStore(initState.tableListParams);
  @observable form = new Form.Store();
  @observable accountId = initState.accountId;
  @observable sentItemsVal = initState.sentItemsVal;

  @action
  setState = (params = {}) => {
    Object.keys(params).forEach(key => {
      this[key] = params[key];
    });
    return this;
  }

  @action
  clear = () => this.setState(initState)
}
